package com.cn.zpark;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: ServletContextDemo02
 * @Description:
 * @author: RZS
 * @date: 2022/4/8  19:41
 */
@WebServlet("/scd2.do")
public class ServletContextDemo02 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         // 获取context对象
        ServletContext context = request.getServletContext();
        // 根据Context对象获取上下文初始化参数
        String username = context.getInitParameter("username");
        System.out.println(username);

    }
}
